package com.HAPOERP.managedBean;

import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import com.HAPOERP_EJB.persistance.Offer;
import com.hapoerpejb.services.OfferDAOLocal;

@ManagedBean(name="offerManaged")
@SessionScoped
public class OfferManaged {
@EJB
OfferDAOLocal OfferLocal;
private Offer offer;
private Offer offerbyid;
private List<Offer> offers;



public Offer getOffer() {
	if(offer==null)
	{
	offer = new Offer();
	}
	return offer;
}

public void setOffer(Offer offer) {
	this.offer = new Offer();
}

public String CreateOffer()
{
	OfferLocal.createOffer(offer);
	return "";
}

public String jobofferid()
{
	return (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("offer");
	
}

public String jobofferid2()
{
	return (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("offer2");
	
}

public List<Offer> getOffers() {
	offers = OfferLocal.findAllOffer();
	return offers;
}

public void setOffers(List<Offer> offers) {
	this.offers = offers;
}

public Offer getOfferbyid() {
	offerbyid = OfferLocal.findOfferById(Integer.parseInt(jobofferid()));
	return offerbyid;
}

public void setOfferbyid(Offer offerbyid) {
	this.offerbyid = offerbyid;
}


}
